<?php
 
/*
 * Following code will list all the products
 */
 
// array for JSON response
$response = array();
 
 // check for required fields
if (isset($_POST['Address'])){
	$Address = $_POST['Address'];
	// include db connect class
	require_once __DIR__ . '/db_connect.php';
	 
	// connecting to db
	$db = new DB_CONNECT();
	 
	// get all products from products table
	$result = mysql_query("SELECT place_name,Address,Count_Like FROM place WHERE Address LIKE '%$Address%'") or die(mysql_error());
	 
	// check for empty result
	if (mysql_num_rows($result) > 0) {
		// looping through all results
		// products node
		$response["place"] = array();
	 
		while ($row = mysql_fetch_array($result)) {
			// temp user array
			$place = array();    
		//$place["Place_ID"] = $row['Place_ID'];
		$place["Place_Name"] = $row['place_name'];
		$place["Address"] = $row['Address'];
		//$place["Longitude"] = $row['Longitude'];
		//$place["Latitude"] = $row['Latitude'];
		//$place["Category_Place_ID"] = $row['Category_Place_ID'];		 
		//$place["Phone_Number"] = $row['Phone_Number'];
		//$place["Fax_Number"] = $row['Fax_Number'];
		//$place["Email"] = $row['Email'];
		//$place["Website"] = $row['Website'];
		//$place["Open_Time"] = $row['Open_Time'];		 
		//$place["Close_Time"] = $row['Close_Time'];
		//$place["Visa_Master"] = $row['Visa_Master'];
		//$place["Car_Parking"] = $row['Car_Parking'];
		//$place["Moto_Parking"] = $row['Moto_Parking'];
		//$place["Delivery"] = $row['Delivery'];		 
		//$place["Wifi"] = $row['Wifi'];
		//$place["Description"] = $row['Description'];
		//$place["Point_Rating"] = $row['Point_Rating'];
		//$place["Count_Rating"] = $row['Count_Rating'];
		$place["Count_Like"] = $row['Count_Like'];
		//$place["Public"] = $row['Public'];		
	 
			// push single product into final response array
			array_push($response["place"], $place);
		}
		// success
		$response["success"] = 1;
	 
		// echoing JSON response
		echo json_encode($response["place"]);
	} else {
		// no products found
		$response["success"] = 0;
		$response["message"] = "No products found";
	 
		// echo no users JSON
		echo json_encode($response);
	}
} else {
    // required field is missing
    $response["success"] = 0;
    $response["message"] = "Required field(s) is missing";
 
    // echoing JSON response
    echo json_encode($response);
}
?>